< previous page page_129 next page >

Page 129
e10a6a0a59f035e870d90cca05b85fce.gif
' See how long the new segment is.
x2 = ptx(pt)
y2 = pty(pt)
dx = x2 - x1
dy = y2 - y1
newavail = Sqr(dx * dx + dy * dy)
avail = avail + newavail

' Create a font along the segment.
If dx > -0.1 And dx < 0.1 Then
    If dy > 0 Then
        theta = PI_OVER_2
    Else
         theta = -PI_OVER_2
    End If
Else
    theta = Atn(dy / dx)
    If dx < 0 Then theta = theta - PI
End If
escapement = -theta * 180# / PI * 10#
newfont = CreateFont(nHeight, nWidth, escapement, 0, _
    fnWeight, fbItalic, fbUnderline, fbStrikeOut,_
    fbCharSet, fbOutputPrecision, fbClipPrecision, _
    fbQuality, fbPitchAndFamily, lpszFace)
oldfont = SelectObject(hdc, newfont)

' Output characters until no more fit.
Do
    ' See how big the next character is.
    ' (Add a little to prevent characters
    ' from becoming too close together.)
    ch = Mid$(txt, chnum, 1)
    needed = TextWidth(ch) * 1.2

    ' If it's too big, get another segment.
    If needed > avail Then Exit Do

    ' See where the character belongs
    ' along the segment.
    CurrentX = x2 - dx / newavail * avail
    CurrentY = y2 - dy / newavail * avail
    If above Then
        ' Place text above the segment.
        CurrentX = CurrentX + dy * nHeight / newavail
        CurrentY = CurrentY - dx * nHeight / newavail
    End If

    ' Display the character.
    Print ch;

 
< previous page page_129 next page >